package com.szrt.java.day20161227.demo02;

import org.junit.Test;

public class RandomStudent {
	
	
	@Test
	public void ran(){
		
		//1 初始化数组
		int len =11;
		String[] class1612 = new String[len];
		class1612[0] = "张泽谋";
		class1612[1] = "吴荣来";
		class1612[2] = "钟鹏";
		class1612[3] = "刘浩";
		class1612[4] = "谢文威";
		class1612[5] = "黄志杰";
		class1612[6] = "张志东";
		class1612[7] = "胡斌";
		class1612[8] = "陈皋";
		class1612[9] = "曾少华";
		class1612[10] = "林天杰";
		
		int counter =1;
		while(counter<=100){
			//2 得到1个随机数 double
			double random = Math.random();
			System.out.println(random);
			
			//3 通过长度和floor的计算得到具体的下标
			int index =(int) Math.floor(random*len);
			System.out.println(class1612[index] + " : " + index);
			counter++;
		}
		
		

		
	}

}
